<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/28
 * Time: 0:34
 */


namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Platform\System\Tools\ResultTool;
use Tymon\JWTAuth\Http\Middleware\BaseMiddleware as JwtBaseMiddleware;

class CheckToken extends JwtBaseMiddleware
{

    public function handle(Request $request, Closure $next,$guard)
    {
        $token = auth($guard)->getToken();
        if ($token) {
            if ($userInfo = auth($guard)->user()) {
                return $next($request);
            }
        }
        myResult()->stop(ResultTool::CODE_NO_LOGIN);
    }
}